package com.yingsheng.bi.hks.web.controller;


import com.yingsheng.bi.hks.basic.utils.Subject;
import com.yingsheng.bi.hks.dto.*;
import com.yingsheng.bi.hks.feign.client.CommFeignClient;
import com.yingsheng.bi.hks.service.comm.ImageUplodadService;
import com.yingsheng.bi.hks.service.comm.SmsBiService;
import com.yingsheng.bi.hks.template.annotation.Template;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

/**
 * 公共服务
 *
 * @author root
 */
@RestController
public class CommCtrl implements CommFeignClient {

    @Autowired
    private SmsBiService smsBiService;

    @Autowired
    private ImageUplodadService imageUplodadService;

    @Template(name = "publicTransTemplate")
    public SmsCodeGetRes process(@Validated SmsCodeGetBeforeLoginReq req) {
        return smsBiService.get(req);
    }

    @Template(name = "accessTransTemplate")
    public SmsCodeGetRes process(@Validated SmsCodeAfterLoginReq req) {
        SmsCodeGetBeforeLoginReq beforeLoginReq = new SmsCodeGetBeforeLoginReq();
        beforeLoginReq.setChannel(req.getChannel());
        beforeLoginReq.setMobile(Subject.get().getMobile());
        beforeLoginReq.setScene(req.getScene());
        return process(beforeLoginReq);
    }

    @Override
    public ImageUploadRes imageUpload(@Validated ImageUploadReq req) {
        return imageUplodadService.imageUplodad(req);
    }

    @Template(name = "accessTransTemplate")
    @Override
    public IdCardOcrRes idCardOcr(@Validated IdCardOcrReq req) {
        return imageUplodadService.idCardOcr(req);
    }

}
